package com.isdepci.project.result.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.result.domain.Source;
import com.isdepci.project.result.service.ISourceService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 范围3分类Controller
 *
 * @author isdepci
 * @date 2023-09-05
 */
@RestController
@RequestMapping("/result/source")
public class SourceController extends BaseController
{
    @Autowired
    private ISourceService sourceService;

    /**
     * 查询范围3分类列表
     */
    @PreAuthorize("@ss.hasPermi('result:source:list')")
    @GetMapping("/list")
    public TableDataInfo list(Source source)
    {
        startPage();
        List<Source> list = sourceService.selectSourceList(source);
        return getDataTable(list);
    }

    /**
     * 导出范围3分类列表
     */
    @PreAuthorize("@ss.hasPermi('result:source:export')")
    @Log(title = "范围3分类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Source source)
    {
        List<Source> list = sourceService.selectSourceList(source);
        ExcelUtil<Source> util = new ExcelUtil<Source>(Source.class);
        return util.exportExcel(list, "source");
    }

    /**
     * 获取范围3分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('result:source:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sourceService.selectSourceById(id));
    }

    /**
     * 新增范围3分类
     */
    @PreAuthorize("@ss.hasPermi('result:source:add')")
    @Log(title = "范围3分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Source source)
    {
        return toAjax(sourceService.insertSource(source));
    }

    /**
     * 修改范围3分类
     */
    @PreAuthorize("@ss.hasPermi('result:source:edit')")
    @Log(title = "范围3分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Source source)
    {
        return toAjax(sourceService.updateSource(source));
    }

    /**
     * 删除范围3分类
     */
    @PreAuthorize("@ss.hasPermi('result:source:remove')")
    @Log(title = "范围3分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sourceService.deleteSourceByIds(ids));
    }
}
